<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<title>小区通知</title>
<link href="/SmartCommunity/css/wechat/main.css" rel="stylesheet">
<script src="/SmartCommunity/js/wechat/iscroll.js"></script>
<script src="/SmartCommunity/js/wechat/pullToRefresh.js"></script>
</head>
<body style="background:#DDDDDD;">
<div class="SpecialTop info-fixed">
	<a class="back" href="javascript:history.back();"></a>
   <div class="renzheng">小区通知</div>
</div>
<div style="visibility:hidden;height:45px"></div>
<div class="main-info" id="wrapper">
 <ul id="info-datas">
   <li class="info-template" style="display:none;"><a href="javascript:void(0);" onclick="send_infoid(this);">
   <div></div>
   <h2></h2>
   <p></p></a>
   </li>
</ul>
 </div>
<script src="/SmartCommunity/js/wechat/jquery-2.2.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
	var height_screen=document.documentElement.clientHeight-45;
	$(".main-info").height(height_screen);
	refresher.init({
		id:"wrapper",//<------------------------------------------------------------------------------------┐
		pullDownAction:Refresh,                                                            
		pullUpAction:Load 																			
		});																						
	var generatedCount = 0;	
	$.ajax({
		type: "POST",
		url: "/SmartCommunity/wechat/get_notices_list",
		contentType: "application/json; charset=utf-8",
		success: function(data){		
			//var arr=eval("["+data+"]");
			var arr=eval("("+data+")");
			for(var i=0;i<arr.length;i++)
			{
				var row = $(".info-template").eq(0).clone();
				row.attr("id",arr[i].id);
				row.find("div").text(arr[i].createTime);
				row.find("h2").text(arr[i].title);
				row.find("p").text(arr[i].summary);
				row.css("display","block");
				row.appendTo("#info-datas");
				 wrapper.refresh();
			}
		},
		error: function(){
		alert("网络请求失败");
		} 
		}); 
		});																	
function Refresh() {																
	 var el,row;																		
		el =document.querySelector("#wrapper ul");	
		$.ajax({
			type: "POST",
			url: "/SmartCommunity/wechat/get_notices_list",
			contentType: "application/json; charset=utf-8", 
			success: function(data){
				var arr=eval(data);
				for(var i=0;i<arr.length;i++)
				{
					var row = $(".info-template").eq(0).clone();
					row.attr("id",arr[i].id);
					row.find("div").text(arr[i].createTime);
					row.find("h2").text(arr[i].title);
					row.find("p").text(arr[i].summary);
					row.css("display","block");
					if(i==0){
					el.innerHTML='';}
					row.appendTo("#info-datas");
				}
				 setTimeout(function(){
	                    wrapper.refresh();
	                },1000);
			},
			error: function(){
			alert("网络请求失败");
			} 
			}); 		
}

function Load() {
	var temp=$("ul li:last-child").attr("id");
	$.ajax({
		type: "POST",
		url: "/SmartCommunity/wechat/get_notices_list?infoid="+temp,
		contentType: "application/json; charset=utf-8",
		success: function(data){
			var arr=eval(data);
			for(var i=0;i<arr.length;i++)
			{
				var row = $(".info-template").eq(0).clone();
				row.attr("id",arr[i].id);
				row.find("div").text(arr[i].createTime);
				row.find("h2").text(arr[i].title);
				row.find("p").text(arr[i].summary);
				row.css("display","block");
				row.appendTo("#info-datas");
			}
			 setTimeout(function(){
                 wrapper.refresh();
             },1000);
		},
		error: function(){
		alert("网络请求失败");
		} 
		}); 		
}
function send_infoid(e){
	var aaa=$(e).parents(".info-template");
	var info_id=aaa.attr('id');
	window.location.href='info-content.html?infoid='+info_id;
}

</script>

</body>
</html>